#include "StdAfx.h"
#include "Utils.h"


Utils::Utils(void)
{
}


Utils::~Utils(void)
{
}

long Utils::getTimeStamp()
{
	SYSTEMTIME tmSys;
    GetLocalTime(&tmSys);
	return tmSys.wMilliseconds;
}

long Utils::getLongFromHMS(CString hour,CString min,CString sec,CString ms)
{
	long lhour = _ttol(hour);
	long lmin = _ttol(min);
	long lsec = _ttol(sec);
	long lms = _ttol(ms);
	long total = lhour * 3600 * 1000 + lmin * 60 * 1000 + lsec * 1000 + lms;
	return total;
}

long Utils::getLongFromHMSFrame(CString hour,CString min,CString sec,CString frame,CString frameRate)
{
	long lhour = _ttol(hour);
	long lmin = _ttol(min);
	long lsec = _ttol(sec);
	long lframe = _ttol(frame);
	long lframeRate = _ttol(frameRate);
	long total = lhour * 3600 * 1000 + lmin * 60 * 1000 + lsec * 1000 + (double)1000 * (double)lframe / (double)lframeRate;
	return total;
}
long Utils::getLongFromHMSFrame(long hour,long min,long sec,long frame,long frameRate)
{
	long total = hour * 3600 * 1000 + min * 60 * 1000 + sec * 1000 + (double)1000 * (double)frame / (double)frameRate;
	return total;
}
long Utils::getHourFromLong(long ms)
{
	return ms / 3600 / 1000;
}
long Utils::getMinFromLong(long ms)
{
	return (ms % (3600 * 1000)) / (60 * 1000);
}
long Utils::getSecFromLong(long ms)
{
	return (ms % (3600 * 1000) % (60 * 1000)) / 1000;
}
long Utils::getMSFromLong(long ms)
{
	return (ms % (3600 * 1000) % (60 * 1000)) % 1000;
}